#include <iostream>
using namespace std;
struct ListNode {
	int val;
	ListNode* next;
	ListNode() : val(0), next(nullptr) {}
	ListNode(int x) : val(x), next(nullptr) {}
	ListNode(int x, ListNode* next) : val(x), next(next) {}
};

class Solution {
public:
	ListNode* swapPairs(ListNode* head) {
		if (!head)return head;
		ListNode* newhead = new ListNode(-1);
		newhead->next = head;
		ListNode* phead = newhead, * cur = phead->next, * next = cur->next;
		if (!next)return head;
		ListNode* nnext = next->next;
		while (cur && next) {
			phead->next = next;
			cur->next = nnext;
			next->next = cur;

			phead = phead->next->next;
			cur = phead->next;
			if (cur)next = cur->next;
			else next = nullptr;

			if (next)nnext = next->next;
			else nnext = nullptr;
		}
		return newhead->next;
	}
};
int main() {

	return 0;
}